import type { Question } from '@/types'
import { http } from '@/utils/http'
import { getBusinessApiPrefix } from '@/utils/config'

/**
 * 根据技术栈ID获取题目列表（包含选项）
 */
export const getQuestionsByTechCodeAPI = (techCode : string) => {
	return http<Question[]>({
		url: `${getBusinessApiPrefix()}/questions/getQuestionsByTechCodeAPI`,
		method: 'POST',
		data: { techCode },
	})
}

/**
 * 根据技术栈ID和分类名称获取题目列表
 */
export const getQuestionsByTechAndCategoryAPI = (techId : string, category : string) => {
	return http<Question[]>({
		url: `${getBusinessApiPrefix()}/questions/getQuestionsByTechAndCategoryAPI`,
		method: 'POST',
		data: { techId, category },
	})
}




/**
 * 根据技术栈ID和分类ID列表获取10条随机题目（用于测试）
 * @param techCode 技术栈编码
 * @param categoryCodes 分类编码列表（逗号分隔，如：java-basic,java-oop）
 */
export const getRandomQuestionsByCategoriesAPI = (techCode : string, categoryCodes : string) => {
	return http<Question[]>({
		url: `${getBusinessApiPrefix()}/questions/getRandomQuestionsByCategoriesAPI`,
		method: 'POST',
		data: { techCode, categoryCodes },
	})
}

/**
 * 根据题目ID获取题目详情及选项
 * @param id 题目ID
 */
export const getQuestionWithOptionsAPI = (id : number) => {
	return http<Question>({
		url: `${getBusinessApiPrefix()}/questions/getQuestionWithOptionsAPI`,
		method: 'POST',
		data: { id },
	})
}